class RapsController < ApplicationController
  # GET /raps
  # GET /raps.json
  def index
    @raps = Rap.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @raps }
    end
  end

  # GET /raps/1
  # GET /raps/1.json
  def show
    @rap = Rap.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @rap }
    end
  end

  # GET /raps/new
  # GET /raps/new.json
  def new
    @rap = Rap.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @rap }
    end
  end

  # GET /raps/1/edit
  def edit
    @rap = Rap.find(params[:id])
  end

  # POST /raps
  # POST /raps.json
  def create
    @rap = Rap.new(params[:rap])

    respond_to do |format|
      if @rap.save
        format.html { redirect_to @rap, notice: 'Rap was successfully created.' }
        format.json { render json: @rap, status: :created, location: @rap }
      else
        format.html { render action: "new" }
        format.json { render json: @rap.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /raps/1
  # PUT /raps/1.json
  def update
    @rap = Rap.find(params[:id])

    respond_to do |format|
      if @rap.update_attributes(params[:rap])
        format.html { redirect_to @rap, notice: 'Rap was successfully updated.' }
        format.json { head :ok }
      else
        format.html { render action: "edit" }
        format.json { render json: @rap.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /raps/1
  # DELETE /raps/1.json
  def destroy
    @rap = Rap.find(params[:id])
    @rap.destroy

    respond_to do |format|
      format.html { redirect_to raps_url }
      format.json { head :ok }
    end
  end
end
